package vip.liux.backend.domain.models.gen;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import vip.liux.backend.infrastructure.constants.GenConst;
import vip.liux.domain.entities.auditing.AuditedEntity;

@Getter
@Setter
@Entity
@Table(name = "gen_data_source")
public class GenDataSource extends AuditedEntity<Long> {

    /**
     * 数据源名称
     */
    @Column(name = "name", nullable = false)
    @NotBlank(message = "数据源名称不能为空")
    private String name;

    /**
     * 数据源类型 (0:hikari 1:druid 2:tomcat 3:dbcp2)
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "type", nullable = false)
    @NotNull(message = "数据源类型不能为空")
    private GenConst.DataSourceType type;

    /**
     * 数据库类型(0:MySQL 1:PostgresSQL 2:Oracle 3:SQL Server)
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "db_type", nullable = false)
    @NotNull(message = "数据库类型不能为空")
    private GenConst.DbType dbType;

    /**
     * 数据源URL
     */
    @Column(name = "url", nullable = false)
    @NotBlank(message = "数据源URL不能为空")
    private String url;

    /**
     * 用户名
     */
    @Column(name = "username", nullable = false)
    private String username;

    /**
     * 密码
     */
    @Column(name = "password", nullable = false)
    private String password;

    /**
     * 是否默认数据源
     */
    @Column(name = "`default`", nullable = false)
    private Boolean defaultDataSource;
}